{
 "metadata": {
  "signature": "sha256:617784ed0269f5ac221d00d849a38dc23cc95e6dbdebf2cca53db07a84b87379"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Frequency swept signals\n",
      "======================================================================\n",
      "\n",
      "This page demonstrates two functions in scipy.signal for generating\n",
      "frequency-swept signals: \\`chirp\\` and \\`sweep\\_poly\\`.\n",
      "\n",
      "Some of these require SciPy 0.8.\n",
      "\n",
      "To run the code samples, you will need the following imports:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "from scipy.signal import chirp, sweep_poly"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Linear Chirp\n",
      "------------\n",
      "\n",
      "Sample code:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "t = np.linspace(0, 10, 5001)\n",
      "w = chirp(t, f0=12.5, f1=2.5, t1=10, method='linear')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/FrequencySweptDemo/chirp_linear.png)\n",
      "\n",
      "Quadratic Chirp\n",
      "---------------\n",
      "\n",
      "Sample code:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "t = np.linspace(0, 10, 5001)\n",
      "w = chirp(t, f0=12.5, f1=2.5, t1=10, method='quadratic')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/FrequencySweptDemo/chirp_quadratic.png)\n",
      "\n",
      "Sample code using \\`vertex\\_zero\\`:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "t = np.linspace(0, 10, 5001)\n",
      "w = chirp(t, f0=12.5, f1=2.5, t1=10, method='quadratic', vertex_zero=False)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/FrequencySweptDemo/chirp_quadratic_v0false.png)\n",
      "\n",
      "Logarithmic Chirp\n",
      "-----------------\n",
      "\n",
      "Sample code:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "t = np.linspace(0, 10, 5001)\n",
      "w = chirp(t, f0=12.5, f1=2.5, t1=10, method='logarithmic')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/FrequencySweptDemo/chirp_logarithmic.png)\n",
      "\n",
      "Hyperbolic Chirp\n",
      "----------------\n",
      "\n",
      "Sample code:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "t = np.linspace(0, 10, 5001)\n",
      "w = chirp(t, f0=12.5, f1=2.5, t1=10, method='hyperbolic')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/FrequencySweptDemo/chirp_hyperbolic.png)\n",
      "\n",
      "Sweep Poly\n",
      "----------\n",
      "\n",
      "Sample code:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p = np.poly1d([0.05, -0.75, 2.5, 5.0])\n",
      "t = np.linspace(0, 10, 5001)\n",
      "w = sweep_poly(t, p)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 9
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "![](files/attachments/FrequencySweptDemo/sweep_poly.png)\n",
      "\n",
      "The script that generated the plots is [here](files/attachments/FrequencySweptDemo/chirp_plot.py)\n"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}